/*
 * This class represents a task of a unique ID and a string to be written to the file.
 */
#ifndef TASK_H_
#define TASK_H_

#include <pthread.h>
#include <string>
using namespace std;


class Task{

private:
	//task id
	int _id;

	//task buffer
	string _data;

	//a conditional variable used to signal that the task has been written to a device
	pthread_cond_t _taskCondVar;

	//boolean variable indicating whether the task was already preformed
	bool _hasBeenWritten;

public:
	//constructor:
	Task(int id, string data);

	//destructor:
	~Task();

	//returns the task's id
	int getID();

	//returns the task's datd
	string getData();

	//returns true if the task was already written, false otherwise:
	bool hasBeenWritten();

	//Changes tasks status to was written
	void taskWasWritten();

	//A conditional variable used by the writer function and by the flushing device
	//to indicate the task was written
	pthread_cond_t* getTaskCondVar();
};

#endif /* TASK_H_ */
